<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>小米商城</title>
		<link rel="stylesheet" type="text/css" href="/xiaomi/Public/css/bootstrap.min.css" />
		<script src="/xiaomi/Public/js/jquery.min.js"></script>
		<link rel="stylesheet" type="text/css" href="/xiaomi/Public/css/type.css" />
	
	<script>
		$(function(){
			$('#search').submit(function(event){
			 	event.preventDefault();
				window.location.href="/xiaomi/index.php?s=/Home/Index/searchGood/keyword/"+$("#keyword").val(); 
			});
		});
	
	</script>
	</head>

	<body class="index_body">

		<!--*****************************************导航栏*****************************************************-->
		<nav class="navbar navbar-inverse navbar-fixed-top">
			<div class="container-fluid">
				<!--小米商城名称以及隐藏内容按钮-->
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
			        <span class="sr-only"></span>
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			    </button>
					<a class="navbar-brand" href="#">小米商城</a>
				</div>
				<!--下拉导航-->
				<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
					<ul class="nav navbar-nav">
						<li class="active">
							<a href="/xiaomi/index.php?s=/Home/Index/index.html">首页</a>
						</li>
						<li class="dropdown">
							<a href="/xiaomi/index.php?s=/Home/Index/classify.html">分类</a>
						</li>
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
								我的 <span class="caret"></span>
							</a>
							<ul class="dropdown-menu">
								<li>
									<a href="/xiaomi/index.php?s=/Home/Cart/index.html">购物车</a>
								</li>
								<li>
									<a href="/xiaomi/index.php?s=/Home/User/order.html">订单</a>
								</li>
								<li>
									<a href="/xiaomi/index.php?s=/Home/User/personalInfo">信息</a>
								</li>
							</ul>
						</li>
					</ul>
					<!--搜索条-->
					<form class="navbar-form navbar-right" id="search">
						<div class="form-group has-feedback">
							<span class="glyphicon glyphicon-search form-control-feedback"></span>
							<input type="search" class="form-control" placeholder="Search for..." autofocus id="keyword">
						</div>
					</form>
					<!--登陆注册连接-->
					<ul class="nav navbar-nav navbar-right">
					    <li>
							<?php if(($_SESSION['userName']) != ""): ?><a>欢迎您，<?php echo (session('userName')); ?></a><?php endif; ?>
						</li>
						<li>
							<a href="/xiaomi/index.php?s=/Home/User/login">登陆</a>
						</li>
						<li>
							<a href="/xiaomi/index.php?s=/Home/User/register">注册</a>
							<!-- "/xiaomi/index.php?s=/Admin/Controller/action" -->
						</li>
					</ul>
				</div>
			</div>
		</nav>
		<!doctype html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>小米商城</title>
		<link rel="stylesheet" type="text/css" href="/xiaomi/Public/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/xiaomi/Public/css/type.css" />
		<link rel="Stylesheet" type="text/css" href="/xiaomi/Public/css/loginDialog.css" />
		<script type="text/javascript" src="/xiaomi/Public/js/jquery.min.js"></script>
		<script type="text/javascript" src="/xiaomi/Public/js/bootstrap.min.js"></script>
		
		<script>


		function total() {
	    	var total=0;
	        for(var i=0;i<$(":checkbox").length;i++)
	           if($(":checkbox:eq("+i+")").prop("checked")){
	        	total+=parseInt($(".price:eq("+i+")").val())*parseInt($(".count:eq("+i+")").val());
	           }
	        $("#total").text(total);
	        $("#totalmoney").val(total);
	        }
		
		//全选
	    function checkedAll() {
	        $(":checkbox").each(function () {
	            $(this).prop("checked", true);
	            $(this).attr("checked", true);
	        });
	        total();
	    }
	    //全不选
	    function notCheckedAll() {
	        $(":checkbox").each(function () {
	            $(this).prop("checked", false);
	            $(this).attr("checked", false);
	        });
	        total();
	    }
		//反选
	    function checkedOthers() {
	        $(":checkbox").each(function () {
	            if (this.checked) {
	                $(this).prop("checked", false);
	                $(this).attr("checked", false);
	            } else {
	                $(this).prop("checked", true);
	                $(this).attr("checked", true);
	            }
	        });
	        total();
	    } 

	    function confir(){
		    var flag=false;
	    		 $(".choose").each(function (i, v) {
	 	            if (v.checked) {
		 	            flag=true;
	 	            }
	 	        });
		 	        if(flag==false){
			 	        alert("请至少勾选一个商品！");
						event.preventDefault();
					}
		}

	  //单个选择时的状态设置
	    $(".choose").click(function () {
	        $(this).each(function (i, v) {
	            if (!v.checked) {
	                $(this).prop("checked", false);
	                $(this).attr("checked", false);
	            } else {
	                $(this).prop("checked", true);
	                $(this).attr("checked", true);
	            }
	        });
	    });
	    
$(function(){
	//购买数量加减
	 $(":checkbox").click(
		function(){total();}
	);   

	 $(".cnt-btnplus").click(function (){
		index=$(".cnt-btnplus").index($(this));
		if($(".countval:eq("+index+")").val()==$(".number:eq("+index+")").val()){alert("已达商品最大库存!");return;};
		var yuanstr=$(".choose:eq("+index+")").val().substring(0,$(".choose:eq("+index+")").val().lastIndexOf('@')+1);
		var num=parseInt($(".count:eq("+index+")").val())+1;
		$(".countval:eq("+index+")").val(num);
		$(".count:eq("+index+")").val(num);
		yuanstr+=num;
		$(".choose:eq("+index+")").val(yuanstr);
		total();
		});


		$(".cnt-btn-").click(function(){
			index=$(".cnt-btn-").index($(this));
			var yuanstr=$(".choose:eq("+index+")").val().substring(0,$(".choose:eq("+index+")").val().lastIndexOf('@')+1);
			var num=parseInt($(".count:eq("+index+")").val())-1;
			if($(".countval:eq("+index+")").val()==1)return;
			$(".countval:eq("+index+")").val(num);
			$(".count:eq("+index+")").val(num);
			yuanstr+=num;
			$(".choose:eq("+index+")").val(yuanstr);
			total();
			});



		//弹出登录
		$("#example").on('click', function () {
			$("body").append("<div id='mask'></div>");
			$("#mask").addClass("mask").fadeIn("slow");
			$("#LoginBox").fadeIn("slow");
		});
		//
		//文本框不允许为空---按钮触发
		$("#loginbtn").on('click', function () {
			var flag=true;
			var txtName = $("#name").val();
			var txtAddress = $("#address").val();
			var txtPhone=$("#phone").val();
			if (txtName == "" || txtName == undefined || txtName == null) {
				$("#warn1").css({ color: 'red' });
				flag=false;
			}
			else {
				$("#warn1").css({ color: 'white' });
			}

			if (txtAddress == "" || txtAddress == undefined || txtAddress == null) {
				$("#warn2").css({ color: 'red' });
				flag=false;
			}
			else {
				$("#warn2").css({ color: 'white' });
			}

			if (txtPhone == "" || txtPhone == undefined || txtPhone == null) {
				$("#warn3").css({ color: 'red' });
				flag=false;
			}
			else {
				$("#warn3").css({ color: 'white' });
			}

			if(flag==false){
	 	        alert("请检查收货信息！");
				event.preventDefault();
			}
			

		});
		//文本框不允许为空---单个文本触发
		$("#name").change(function () {
			var txtName = $(this).val();
			if (txtName == "" || txtName == undefined || txtName == null) {
				$("#warn1").css({ color: 'red' });
			}
			else {
				$("#warn1").css({ color: 'white' });
			}
		});

		$("#address").change(function () {
			var txtName = $(this).val();
			if (txtName == "" || txtName == undefined || txtName == null) {
				$("#warn2").css({ color: 'red' });
			}
			else {
				$("#warn2").css({ color: 'white' });
			}
		});

		$("#phone").change(function () {
			var txtName = $(this).val();
			if (txtName == "" || txtName == undefined || txtName == null) {
				$("#warn3").css({ color: 'red' });
			}
			else {
				$("#warn3").css({ color: 'white' });
			}
		});

		
		//关闭
		$(".close_btn").hover(function () { $(this).css({ color: 'black' }) }, function () { $(this).css({ color: '#999' }) }).on('click', function () {
			$("#LoginBox").fadeOut("fast");
			$("#mask").css({ display: 'none' });
		});



		
});
	
		
		</script>
		
		<style type="text/css">
			.cart-items {
				width: 70%;
				margin-right: 5%;
			}
			
			.cart_span1 {
				font-size: 16px;
			}
			
			.cart_span2 {
				font-size: 14px;
				color: #ADADAD;
			}
			
			.cart_span3 {
				color: #FB741F;
				font-size: 14px;
			}
			
			.cart-header {
				position: relative;
			}
			
			.cart-header2 {
				position: relative;
				clear:leftl;
			}
			/*del*/
			
			.close1,
			.close2 {
				background: url('/xiaomi/Public/images/cart/close_1.png') no-repeat 0px 0px;
				cursor: pointer;
				width: 28px;
				height: 28px;
				position: absolute;
				right: 0px;
				top: 0px;
			}
			/*信息位置*/
			
			.cart-item {
				width: 20%;
				float: left;
				margin-right: 5%;
			}
			
			a.continue {
				background: #5B88BB;
				padding: 10px 20px;
				font-size: 1em;
				color: #000;
				text-decoration: none;
				display: block;
				text-align: center;
				margin-bottom: 2em;
			}
			
			.price-details {
				border-bottom: 1px solid #DDD9D9;
				padding-bottom: 10px;
			}
			/*右边列表*/
			
			.price-details span {
				width: 50%;
				float: left;
				font-size: 1em;
				color: #000;
				line-height: 1.8em;
				text-align: center;
			}
			
			.cart_total {
				text-align: center;
			}
			/*--responsive design--*/
			
			@media (max-width:1024px) {
				.cart-items {
					width: 100%;
					margin-right: 0;
				}
			}
			
			/*购物车列表样式*/
			.cart{
			     clear:left;
			     list-type:none;
			}
			.cart li{
			      width:100px;
			}
		</style>
	</head>

	<body>
		<header>
			<div class="col-md-12 col-xs-12">
				<div class="col-md-4 col-xs-3"></div>
				<div class="col-md-4 col-xs-6 text-center">
					<h2>购物车</h2></div>
				<div class="col-md-4 col-xs-3"></div>
			</div>
			<div class="col-md-12 col-xs-12">
				<div class="col-md-1"></div>
				<div class="col-md-10 col-xs-12">
					<hr style="border: groove #ddd 1px;">
				</div>
				<div class="col-md-1"></div>
			</div>
		</header>
		<?php if(($cart) != ""): ?><form method="post" action="/xiaomi/index.php?s=/Home/User/addorder">
		<section>
		 <div id="LoginBox">
		 <center> 
        <div class="row1">
            请填写收货信息<a href="javascript:void(0)" title="关闭窗口" class="close_btn" id="closeBtn">×</a>
        </div>
        <div class="row">
            收件人：&emsp;
                <input type="text"  class="inputbox" id="name" value="<?php echo ($UserName); ?>" name="PickName"/>
            <span class="warning" id="warn1">*</span>
        </div>
        <div class="row">
            收件地址：
                <input type="text" class="inputbox" id="address" value="<?php echo ($Address); ?>" name="ImportAddress"/>
            <span class="warning" id="warn2">*</span>
        </div>
        <div class="row">
            收件电话：
                <input type="text" class="inputbox" id="phone" value="<?php echo ($Phone); ?>" name="PickPhone"/>
            <span class="warning" id="warn3">*</span>
        </div>
        <div class="row">
            备注：&emsp;&emsp;
                <input type="text" class="inputbox" value="" name="Remark"/>
                <span class="warning">*</span>
        </div>
        <div class="row">
          <button type="submit" onclick="confir()" class="btn btn-primary" id="loginbtn">提交订单</button>
        </div>
        </center>
    </div>
			<div class="col-md-1"></div>
			<div class="container col-md-10 col-xs-12">
				<div class="check_box">
					<div class="col-md-8 cart-items ">
		            
						<script>
							$(document).ready(function(c) {
								$('.close2').on('click', function(c) {
									$('.cart-header2').fadeOut('slow', function(c) {
										$('.cart-header2').remove();
									});
								});
								
							});
						</script>
						<div class="cart-header2">&emsp;
						<a href="#" onclick="checkedAll()">全选</a> &emsp;
						<a href="#" onclick="notCheckedAll()">全不选</a>&emsp;
						<a href="#" onclick="checkedOthers()">反选</a>&emsp;
					<br><br>
							<?php if(is_array($cart)): foreach($cart as $key=>$c): ?><input type="hidden" value="<?php echo ($c["Number"]); ?>" class="number">
							<div class="cart-sec">
								<div class="cart-item">
								<table>
									<tr>
										<td><input type="checkbox" name="goodids[]" class="choose" value="<?php echo ($c["GoodId"]); ?>@@@<?php echo ($c["Color"]); ?>@@@<?php echo ($c["Version"]); ?>@@@<?php echo ($c["Count"]); ?>"></td>
										<td><a href="/xiaomi/index.php?s=/Home/Index/goods/gid/<?php echo ($c["GoodId"]); ?>"><img src="/xiaomi/Public/uploads/img/<?php echo ($c["PictureUrl"]); ?>" class="img-responsive" alt="" style="display: inline-block;"/></a></td>
									</tr>
								</table>
								</div>
								<div class="cart_info">
								<input type="hidden" value="<?php echo ($c["GoodId"]); ?>" name="GoodId[]"/>
								<a href="/xiaomi/index.php?s=/Home/Index/goods/gid/<?php echo ($c["GoodId"]); ?>">	<span class="cart_span1"><?php echo ($c["GoodName"]); ?></span><br><input type="hidden" value="<?php echo ($c["GoodName"]); ?>" name="GoodName[]"/>
									<div class="col-md-3 col-xs-3 index_span2">
										<span class="cart_span2"><?php echo ($c["Color"]); ?></span><br><input type="hidden" value="<?php echo ($c["Color"]); ?>" name="Color[]"/>
										<span class="cart_span2"><?php echo ($c["Version"]); ?></span><input type="hidden" value="<?php echo ($c["Version"]); ?>" name="Version[]"/>
										</div>
										</a>
									</div>
									<div class="col-md-1 col-xs-1"></div>
									<div  class="" style="margin-top:-3%;margin-bottom:2%;">
									<input  type="text" class="countval" class="col-md-3 col-xs-3" value="<?php echo ($c["Count"]); ?>" readonly style="margin-bottom: 3%; margin-left: -3%; margin-right: 3%;margin-top:-3%"/>
										<input type="button" value="-" class="cnt-btn-">
										<input type="hidden" value="<?php echo ($c["Count"]); ?>" name="GoodCount[]" class="count"/>
										<input type="button" value="+" class="cnt-btnplus">
									</div>
										
									<div class="col-md-1 col-xs-1"></div>
									<div class="col-md-2 col-xs-3 index_span3">
										<span class="cart_span3"> <?php echo ($c["Price"]); ?></span><input type="hidden" value="<?php echo ($c["Price"]); ?>" name="Price[]" class="price"/>
									</div>
									<div class="col-md-2 col-xs-3 index_span3">
										<span class="cart_span3"><a href="/xiaomi/index.php?s=/Home/Cart/del/gid/<?php echo ($c["GoodId"]); ?>/userId/<?php echo ($c["user_UserId"]); ?>/color/<?php echo ($c["Color"]); ?>/version/<?php echo ($c["Version"]); ?>">删除</a></span>
									</div>
									<div class="clearfix"></div>
								
							</div>
							<hr><?php endforeach; endif; ?>

						</div>
					</div>
				</div>

				<div class="col-md-3">
					<a class="continue" href="#">价格明细</a>
					
					<div class="price-details">

						<span>总价：</span>
						<span id="total">0</span>
<input type="hidden" value="0" name="TotalMoney" id="totalmoney"/>
						<div class="clearfix"></div>
					</div>
					
				</div>
				<div class="col-md-1"></div>
		</section>
		<div class="col-md-12 col-xs-12">
			<div class="col-md-4"></div>
			<div class="col-md-4 cart_total">
			 <a href="#" id="example">结算</a></div>
			<div class="col-md-4"><br><br><br></div>
		
		</div>
		
		
</form><?php endif; ?>
<?php if(($cart) == ""): ?><center><h2>还没有添加商品，快去<a href="/xiaomi/index.php?s=">采购</a>吧~</h2></center><?php endif; ?>
	</body>

</html>
	
</body>
</html>